package com.wanmait.houlang.controller;

import com.github.pagehelper.PageInfo;
import com.wanmait.houlang.pojo.*;

import com.wanmait.houlang.service.*;
import com.wanmait.houlang.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.lang.System;
import java.util.List;
@CrossOrigin
@RestController
@RequestMapping("/webContent")
public class SearchSchoolController {
    @Resource
    private DistrictService districtService;
    @Resource
    private SchoolTypeService schoolTypeService;
    @Resource
    private SchoolChracteristicsService schoolChracteristicsService;
    @Resource
    private RunChracteristicsService runChracteristicsService;
    @Resource
    private ProfessionalLevelService professionalLevelService;
    @Resource
    private SchoolService schoolService;
    @Resource
    private ScCagRelationService scCagRelationService;

    @GetMapping("district")
    public Result searchDistrict(){
        List<District> districts = districtService.findAll();
        return Result.success(districts);
    }

    //查询所有院校类型
    @GetMapping("schoolType")
    public Result SchoolqueryAll(){
        List<SchoolType> schoolType=  schoolTypeService.findAll();
        return Result.success(schoolType);
    }
    //查询所有办学特色
    @GetMapping("SchoolChracteristics")
    public Result Characteristic (){
      List<SchoolChracteristics> schoolChracteristics= schoolChracteristicsService.findAll();
        return  Result.success(schoolChracteristics);
    }
    //特征
    @GetMapping("RunChracteristics")
    public Result runChracteristics(){
      List<RunChracteristics>  runChracteristics= runChracteristicsService.findAll();
        return Result.success(runChracteristics);
    }
    //职业水平
    @GetMapping("ProfessionalLevel")
    public   Result ProfessionalLevelAll(){
      List<ProfessionalLevel> ProfessionalLevelAll=  professionalLevelService.findAll();
        return Result.success(ProfessionalLevelAll);
    }
    //根据条件获取所有的学校
    @PostMapping("school")
    public Result searchSchool(Integer pageNum,@RequestBody DTO dto){
        int pageSize=5;

        PageInfo<School> all = schoolService.findAll(pageNum,pageSize,dto);
        return Result.success(all);
    }

    //根据id查询学校

    @GetMapping("/schoolInfo/{id:\\d+}")
    public Result searchSchoolById(@PathVariable("id") Integer schoolId){
        School schoolById = schoolService.findById(schoolId);
        return Result.success(schoolById);
    }

    @GetMapping("")
    public  Result Learningquery(Integer id){
     ScCagRelation Learning=   scCagRelationService.LearningID(id);
        return Result.success(Learning);
    }
}
